package sctu.edu.java.year2016.team04.luoxinghua.day20160601.chapter9_3;

/**
 * 创建一个接口，在接口定义一个方法 然后创建一个类，在类中定义一个形参为接口类型的方法，并调用接口中的方法
 * 在类的方法中创建一个实现接口的匿名内部类，用于实现接口中的方法
 * Created by 落叶的思恋 on 2016/5/31.
 */

import sctu.edu.java.year2016.team01.chenhong.day20160524.chapter7_1.Work;


import java.util.Scanner;
interface Person {
    String eat();
}
public class Work93 {
    void study(String name) {
        if (name.equals("xiaohong"))
            System.out.println(name + " in learning");
          else if (name.equals("xiaoming"))
                System.out.println(name + " at play");
             else
                 System.out.println("I don't know");
        Person p = new Person() {
            @Override
            public String eat() {
                if (name.equals("xiaohong"))
                    System.out.println(name + " full");
                else
                    System.out.println(name + " didn't eat satisfied");
                return name;
            }
        };
        p.eat();
    }

    public static void main(String[] args) {
        Scanner scanf = new Scanner(System.in);
        System.out.println("look at the student（输入学生姓名）");
        String str = scanf.nextLine();
        Work93 work = new Work93();
          work.study(str);

    }

}